home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------------
- #include <vcl\vcl.h>
- #pragma hdrstop
-
- #include "Monstr7a.h"
- //---------------------------------------------------------------------------
- #pragma resource "*.dfm"
-
- const String Pfad = "c:\\cpp\\buch\\";
-
- class TMonster
- {
- public:
- virtual void Erscheinen(String Bild);
- };
-
- //---------------------------------------------------------------------------
-
- TMonster WerWohl;
- bool Modus;
- int Zufall;
- TForm1 *Form1;
-
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void TMonster::Erscheinen (String Bild)
- {
- String Name = Bild.SubString(1, Bild.Length()-4);
- Form1->Image1->Picture->LoadFromFile (Pfad+Bild);
- Form1->Panel1->Caption = Name;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- randomize ();
- Timer1->Interval = 500;
- Timer1->Enabled = false;
- Modus = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- if (Modus)
- {
- Timer1->Enabled = true;
- Button1->Caption = "Stop";
- }
- else
- {
- Timer1->Enabled = false;
- Button1->Caption = "Start";
- }
- Modus = !Modus;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Timer1Timer(TObject *Sender)
- {
- Zufall = random(5);
- switch (Zufall)
- {
- case 0:
- WerWohl.Erscheinen ("Frank.bmp");
- break;
- case 1:
- WerWohl.Erscheinen ("Albert.bmp");
- break;
- case 2:
- WerWohl.Erscheinen ("Sigmund.bmp");
- break;
- case 3:
- WerWohl.Erscheinen ("Jekyll.bmp");
- break;
- case 4:
- WerWohl.Erscheinen ("Hyde.bmp");
- }
- }
- //---------------------------------------------------------------------------
-